package org.jeecg.modules.demo.znnqjc.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.demo.znnqjc.entity.ZwglZdfxfb;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;

/**
 * @Description: 诊断分析附表
 * @Author: jeecg-boot
 * @Date:   2023-04-20
 * @Version: V1.0
 */
@Mapper
public interface ZwglZdfxfbMapper extends BaseMapper<ZwglZdfxfb> {

	/**
	 * 通过主表id删除子表数据
	 *
	 * @param mainId 主表id
	 * @return boolean
	 */
	public boolean deleteByMainId(@Param("mainId") String mainId);

   /**
    * 通过主表id查询子表数据
    *
    * @param mainId 主表id
    * @return List<ZwglZdfxfb>
    */
	public List<ZwglZdfxfb> selectByMainId(@Param("mainId") String mainId);

	@Select("SELECT dj,main_id, ROUND(SUM(mj),3) AS total_sum " +
			"FROM zwgl_zdfxfb " +
			"WHERE main_id = #{mainId} " +
			"GROUP BY dj")
	List<Map<String, Object>> selectTotalSumGroupedByDj(@Param("mainId") String mainId);

}
